import socket
def request1(host, port=80):
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((host, port))
    REQUEST = b'GET / HTTP/1.1\r\nHost: HOST\r\nConnection: close\r\n\r\n'
    REQUEST = REQUEST.decode().replace('HOST', host).encode()
    s.send(REQUEST)
    buffer = s.recv(10240000)
    s.close()
    return buffer.decode()

def request2(host, port=80):
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((host, port))
    REQUEST = b'GET / HTTP/1.1\r\nHost: HOST\r\n\r\n'
    REQUEST = REQUEST.decode().replace('HOST', host).encode()
    s.send(REQUEST)
    buffer = []
    while True:
        d = s.recv(1024)
        if d:
            buffer.append(d) 
        else:
            break 
    data = b''.join(buffer)
    s.close()
    return data.decode()

print(request1('www.baidu.com'))